//
//  HPCalendarContentCell.m
//  HappyPenguin
//
//  Created by zhuangyihang on 1/7/16.
//  Copyright © 2016 zhuangyihang. All rights reserved.
//

#import "HPSecondTabContentCell.h"
#import "UIConstants.h"

static const NSInteger kBadgeViewFontSize = 12;
static const NSInteger kBadgeViewWidth = 17;
static const NSInteger kBadgeViewMarginRight = 0;

@interface HPSecondTabContentCell()

@property (nonatomic, strong) UILabel *badgeLabel;

@end

@implementation HPSecondTabContentCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.badgeLabel = [UILabel new];
        [self.contentView addSubview:self.badgeLabel];
        self.badgeLabel.layer.cornerRadius = kBadgeViewWidth/2;
        self.badgeLabel.backgroundColor = [UIColor colorWithRGB:0xd42f21];
        self.badgeLabel.clipsToBounds = YES;
        [self.badgeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.height.mas_equalTo(kBadgeViewWidth);
            make.centerY.equalTo(self.contentView);
            make.right.equalTo(self.contentView).offset(kBadgeViewMarginRight);
        }];
        self.badgeLabel.font = [UIConstants getFont:kBadgeViewFontSize];
        self.badgeLabel.textColor = [UIColor whiteColor];
        self.badgeLabel.textAlignment = NSTextAlignmentCenter;
        
        self.textLabel.font = [UIConstants getFont:16];
        
    }
    return self;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setBadgeView:(NSInteger)badge{
    self.badgeLabel.text = [NSString stringWithFormat:@"%ld",(long)badge];
}

+ (CGFloat)getCellHeight{
    return 50;
}

@end
